package com.sky.controller.admin;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName: ShopController
 * Description:
 *
 * @Author HTAO
 * @Create 2023/11/3 15:13
 */
@RestController
@RequestMapping("/admin/shop")
@Api(tags = "店铺相关接口")
@Slf4j
public class ShopController {

    @Autowired
    RedisTemplate redisTemplate;


    public static final String key = "SHOP_STATUS";

    @PutMapping("/{status}")
    @ApiOperation("营业状态改变")
    public Result setStatus(@PathVariable Integer status){
        log.info("店铺状态：{}",status);
        redisTemplate.opsForValue().set(key,status);
        return Result.success();
    }
    @GetMapping("/status")
    @ApiOperation("营业状态获取")
    public Result<Integer> setStatus(){
        log.info("店铺状态获取");
        Integer status = (Integer) redisTemplate.opsForValue().get(key);
        return Result.success(status);
    }

}
